home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 7
/
Aminet 7 - August 1995.iso
/
Aminet
/
comm
/
net
/
PPP1_30.lha
/
PPP
/
src
/
PPPConfigAmiTCP30b.c
< prev
Wrap
C/C++ Source or Header
|
1995-01-06
|
2KB
|
70 lines
#include <exec/types.h>
#include <exec/io.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *versionstring="$VER: PPPConfigAmiTCP30b 1.2 (06.01.95)";
char *copyright="Copyright (C) 1994,1995 by Holger Kruse";
void main(int argc,char *argv[]) {
char localadr[64],remoteadr[64],envname[64];
int len,unit;
FILE *f;
if(argc==0)
exit(0);
if((argc<2)||(argc>3)) {
printf("Usage: %s unit [machinename]\n",argv[0]);
exit(0);
}
unit=atoi(argv[1]);
sprintf(envname,"ENV:ppp%dIPLocal",unit);
if(!(f=fopen(envname,"r"))) {
printf("Can't find %s !\n",envname);
exit(0);
}
len=fread(localadr,1,64,f);
localadr[len]=0;
fclose(f);
sprintf(envname,"ENV:ppp%dIPRemote",unit);
if(!(f=fopen(envname,"r"))) {
printf("Can't find %s !\n",envname);
exit(0);
}
len=fread(remoteadr,1,64,f);
remoteadr[len]=0;
fclose(f);
if(!(f=fopen("AmiTCP:db/netdb-myhost-tmp","w"))) {
printf("Can't open netdb-myhost-tmp !\n");
exit(0);
}
if(argc==3)
fprintf(f,"add HOST %s %s\n",localadr,argv[2]);
fclose(f);
if(argc==2) {
if(!(f=fopen("T:AmiTCP.rexx","w"))) {
printf("Can't open T:AmiTCP.rexx !\n");
exit(0);
}
fprintf(f,"/* temporary ARexx program to update AmiTCP's database */\n\n");
fprintf(f,"address AMITCP\n");
fclose(f);
}
if(!(f=fopen("T:AmiTCP.tmp","w"))) {
printf("Can't open T:AmiTCP.tmp !\n");
exit(0);
}
fprintf(f,"AmiTCP:bin/ifconfig lo0 localhost\n");
fprintf(f,"AmiTCP:bin/ifconfig ppp%d %s %s\n",unit,
localadr,remoteadr);
fprintf(f,"AmiTCP:bin/route add %s localhost\n",localadr);
fprintf(f,"AmiTCP:bin/route add default %s\n",remoteadr);
if(argc==2) {
fprintf(f,"echo \"*\"`AmiTCP:bin/resolve %s`*\"\" >>T:AmiTCP.rexx\n",localadr);
fprintf(f,"rx T:AmiTCP.rexx\n");
}
fclose(f);
}